import Message from "./Message";
import Vue from "vue";

//创建Message组件构造函数
const MessageConstructor = Vue.extend(Message);

const serve = (message) => {
    //创建message实例
    let messageInstance = new MessageConstructor();
    //将实例挂载到指定的元素
    messageInstance.$mount(document.createElement("div"));
    //将组件挂载的元素插入body
    document.body.appendChild(messageInstance.$el);

    messageInstance.message = message;
    messageInstance.visible = true
    Vue.nextTick(() => {
        setTimeout(() => {
            messageInstance.visible = false
        }, 2000);
    })

}

export default serve